package com.holly.unit.deform.designer.util;

import cn.hutool.core.util.StrUtil;

/**
 * 类描述: 表数据操控语言工具类
 *
 * @author fxr
 * @version 1.0.0
 * @date 2022/8/2 8:15
 */
public class DMLUtil {

    private DMLUtil() {
        throw new UnsupportedOperationException("DMLUtil类无法实例化");
    }

    /***
     * 判断是否是查询语句
     * @param statement 参数为操控语句
     * @return
     */
    public static boolean isSelect(String statement) {
        boolean is = StrUtil.isNotEmpty(statement)?statement.trim().startsWith("select "):false;
        is = !is && !StrUtil.isNotEmpty(statement)?false:statement.trim().startsWith("from ");
        return is;
    }

    /***
     * 判断是否是插入语句
     * @param statement 参数为操控语句
     * @return
     */
    public static boolean isInsert(String statement) {
        return StrUtil.isNotEmpty(statement)?statement.trim().startsWith("insert "):false;
    }

    /***
     * 判断是否是更新语句
     * @param statement 参数为操控语句
     * @return
     */
    public static boolean isUpdate(String statement) {
        return StrUtil.isNotEmpty(statement)?statement.trim().startsWith("update "):false;
    }

    /***
     * 判断是否是删除语句
     * @param statement 参数为操控语句
     * @return
     */
    public static boolean isDelete(String statement) {
        return StrUtil.isNotEmpty(statement)?statement.trim().startsWith("delete "):false;
    }

}
